;(function () {
    function DocumentFont() {
    };
    DocumentFont.set = function () {
        var iWidth = document.documentElement.getBoundingClientRect().width;
        iWidth = iWidth > 640 ? 640 : iWidth;
        iWidth = iWidth < 300 ? 300 : iWidth;
        document.getElementsByTagName("html")[0].style.fontSize = iWidth / 3.2 + "px";
    };
    window.DocumentFont = new DocumentFont();
    DocumentFont.set();
})();
//loading
;(function(){
	function ajaxLoading(){
	};
	ajaxLoading.prototype.open = function(fng){
		this.dom = $("<div>",{"class":"ajax_loading ajax_loading2","id":"ajax_loading"})
		var options = $.extend(true, {
			target:"body"
		}, fng);
		options.target != "body" ? this.dom.addClass("absolute") : "";
		$(options.target).append(this.dom);
	};
	ajaxLoading.prototype.remove = function(fng){
		this.dom.fadeOut(300,function(){
			$(this).remove();
		});
	};         
	window.AjaxLoading = ajaxLoading;
}());
var ajaxLoading;
//console.log(window.location.origin);
var __webState = "debug";
var popWrap;
var _CONFIG = {
    //HOST_URL: "http://10.0.10.63:6677" + "/assets/",//静态资源
    //imgDefault: window.location.origin + "/app/1.0/",//默认图片地址
    debug:{
        HOST_URL: window.location.origin + "/app/1.0/assets/",//静态资源地址
        AJAX_URL: "http://10.0.10.63:6677/",//ajax请求
    //AJAX_URL: "http://192.168.1.39:8001/",//ajax请求
        homePage_URL: window.location.origin + "/app/1.0/html/Reservation/IndexPage.html",// 首页
        subClassPage_URL: window.location.origin + "/app/1.0/html/Reservation/subClassPage.html",// 热门品类
        goodsPage_URL: window.location.origin + "/app/1.0/html/Reservation/goodsPage.html",// 商品详情
        classPage_URL: window.location.origin + "/app/1.0/html/Reservation/classPage.html",// 分类查询
        shoppingCarPage_URL: window.location.origin + "/app/1.0/html/Reservation/shoppingCarPage.html",// 分类查询
        listPage_URL: window.location.origin + "/app/1.0/html/Reservation/listPage.html",// 商品详情地址
        fillOrderPage_URL: window.location.origin + "/app/1.0/html/Reservation/fillOrderPage.html",// 填写订单
        orderDetails :window.location.origin + "/app/1.0/html/PersonalCenter/detailed.html",// 订单详情
        orderAfterSales :window.location.origin + "/app/1.0/html/PersonalCenter/aftersales.html"// 申请售后服务
     },
    ol:{
        HOST_URL: "http://10.0.10.63:6677/assets/",//静态资源地址
        AJAX_URL: "http://10.0.10.63:6677/",//ajax请求
        subClassPage_URL: "/Home/HotProduct",// 热门品类
        goodsPage_URL: "/Home/ProductDetail",// 商品详情
        classPage_URL: "/Home/CategoryQuery",// 分类查询
        shoppingCarPage_URL: "/Order/ShopCart",// 分类查询
        listPage_URL: "/Home/ProductList",// 商品详情地址
        fillOrderPage_URL: window.location.origin + "/app/1.0/html/Reservation/fillOrderPage.html",// 填写订单]
        orderDetails :window.location.origin + "/app/1.0/html/PersonalCenter/detailed.html",// 订单详情
        orderAfterSales :window.location.origin + "/app/1.0/html/PersonalCenter/aftersales.html"// 申请售后服务
    }
};
//获取浏览器参数
function parse_url(url) {
    var pattern = /(\w+)=([^\#&]*)/ig;
    var parames = {};
    url.replace(pattern, function (attr, key, value) {
        parames[key] = decodeURI(value);
    });
    return parames;
};
/*;(function(w,j,d){
    j.fn.tap = function(fn){
        if(!("_tommyfoks_tapPlugin" in window)){
            window._tommyfoks_tapPlugin = [];
        }
        var collection = this,
        isTouch = "ontouchend" in document.createElement("div"),
        tstart = isTouch ? "touchstart" : "mousedown",
        tmove = isTouch ? "touchmove" : "mousemove",
        tend = isTouch ? "touchend" : "mouseup",
        tcancel = isTouch ? "touchcancel" : "mouseout";
        collection.each(function(){
            var i = {};
            i.target = this;
            _tommyfoks_tapPlugin.push(i);
            j(i.target).on(tstart,function(e){
                var p = "touches" in e ? e.touches[0] : (isTouch ? window.event.touches[0] : window.event);
                i.startX = p.clientX;
                i.startY = p.clientY;
                i.endX = p.clientX;
                i.endY = p.clientY;
                i.startTime = + new Date;
                //e.preventDefault();
            });
            j(i.target).on(tmove,function(e){
                    var p = "touches" in e ? e.touches[0] : (isTouch ? window.event.touches[0] : window.event);
                i.endX = p.clientX;
                i.endY = p.clientY;
            });
            j(i.target).on(tend,function(e){
                if((+ new Date)-i.startTime<300){
                    if(Math.abs(i.endX-i.startX)+Math.abs(i.endY-i.startY)<20){
                        fn.call(i.target,e);
                    }
                }
                i.startTime = undefined;
                i.startX = undefined;
                i.startY = undefined;
                i.endX = undefined;
                i.endY = undefined;
                e.preventDefault();
            });
        }); 
        return collection;
    };
})(window,jQuery,document)   */
    

/**
 * 页面初始化类
 * **/
(function (j, d) {
    function pageInit() {
        this.clientWidth = $(window).width();
        this.bannerObj = null;
        this.ModelId = 0;
        this.transitionName = (function (temp) {
            var props = ['WebkitTransition', 'MozTransition', 'OTransition', 'msTransition'];
            for (var i in props) if (temp.style[props[i]] !== undefined) return props[i];
            return false;
        })(document.createElement('isTransition'));
        this.transformName = (function (temp) {
            var props = ['transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform'];
            for (var i in props) if (temp.style[props[i]] !== undefined) return props[i];
            return false;
        })(document.createElement('isTransform'));
        return this;
    };
    pageInit.prototype = {
        // 预定流程
        "RV": function (modelArray) {
            var G = this;
            ajaxLoading.open();
            require(["views/reservation.min"],function(){
            	__base.init.call( G, modelArray );
            })
        },
        // 个人中心流程
        "PC": function (modelArray) {
            var G = this;
            ajaxLoading.open();
            require(["views/personalcenter.min"],function(){
                __base.init.call( G, modelArray );
            })

        }
    };
    require.config({
        baseUrl: _CONFIG[__webState]["HOST_URL"] + 'js',
        paths: {
            "mock":"libs/mock.min",
            "jquery": "libs/jquery-1.11.3.min",
            "tap": "plugins/jquery.tap.min",
            "lazyload":"plugins/lazyload.min",
            "allTpl": "views/tpl/template.min",
            "swiper": "plugins/swiper.3.2.5.min",
            "dropload": "plugins/dropload.min",
            "rangeslider": "plugins/rangeslider.min",
            "page": "control/page.min",
            "popWrap": "control/pop.min",
            "dateRangePicker": "control/jquery.dateRangePicker.min",
            "validate":"control/validate.min",
            "cookie":"plugins/jquery.cookie.min"
        },
        waitSeconds: 15,
        map: {
            '*': {
                'css': 'libs/css.min'
            }
        },
        shim: {
            //'allTpl': {
            //    exports: 'template'
            //},
            'cookie': {
                deps: ['jquery']
            },
            'page': {
                deps: ['jquery']
            },
            'lazyload': {
                deps: ['jquery']
            },
            'rangeslider': {
                deps: ['jquery', "css!../css/plugins/rangeslider.min.css"]
            },
            'popWrap': {
                deps: ['jquery'],
                exports: 'popWrap'
            },
            'mock': {
                exports: 'Mock'
            },
            "tap": {
                deps: ['jquery'],
                exports: 'jQuery.fn.tap'
            },
            "dateRangePicker": ["jquery", "css!../css/control/datepicker.css"],
            "swiper": ["jquery", "css!../css/plugins/swiper.min.css"],
            "dropload": ["jquery", "css!../css/plugins/dropload.min.css"]
        }
    });
    /**
     * 异步调用插件代码位置
     * **/
    require(["jquery", "tap", "popWrap"], function (j) {
        popWrap = new popF();
        ajaxLoading = new AjaxLoading();
        j(d).ready(function () {
            var _Page = j('html>body').data('page');//获取页面标识
            if (!_Page) { return false; } // 没有标示不加载模块功能

            var _pageArray = _Page.split("-"),
                _pageType = _pageArray[0];  //页面类型  RV : 预定流程  PC: 个人中心
             _pageArray.splice(0, 1);
            var _pageModel = _pageArray, //页面模块数组
                 _pageInit = new pageInit(_Page);
            //console.log(_pageInit);

            //try {
                 _pageInit[_pageType].call(_pageInit, _pageModel);
            //} catch(error) {
            //    console.error("body上找不到页面调用标示模块:", _Page);
            //}

        });
		//添加config配置文件
		_CONFIG[__webState].noMoreData=$("<div>",{"class":"noData","text":"已经是最后一条了"})
		_CONFIG[__webState].noOrderData=$("<div>",{"class":"listNull","html":"<span>&#xe92b;</span><p>还没有相关订单！</p>"})
		_CONFIG[__webState].noData=$("<div>",{"class":"noData","text":"没有数据"})
		_CONFIG[__webState].noCartData=$("<div>",{"class":"noCartData","html":"<i class='icon2'></i><span class='txt'>购物车中还没有商品，<a href='"+_CONFIG[__webState].homePage_URL+"'>赶紧选购吧！</a></span>"});
		//_CONFIG[__webState].noProductData=$("<div>",{"class":"nf-pro-content","html":'<span class="result">抱歉，没有找到与相关的商品</span><p>建议您：</p><p>1、适当减少筛选条件</p><p>2、调整价格区间</p><p>3、尝试其他关键字</p><a class="btn btn-default mt20" href="javascript:window.history.back()">返回上一步操作</a></p>'});
		//_CONFIG[__webState].noProductData=$("<div>",{"class":"nf-pro-content","html":'<span class="result">抱歉，没有找到与相关的商品</span><p>建议您：</p><p>1、适当减少筛选条件</p><p>2、调整价格区间</p><p>3、尝试其他关键字</p><a class="btn btn-default mt20" href="javascript:void(0)">返回上一步操作</a></p>'});
		_CONFIG[__webState].noProductData=$("<div>",{"class":"nf-pro-content","html":'<span class="result">抱歉，没有找到与相关的商品</span><p>建议您：</p><p>1、适当减少筛选条件</p><p>2、调整价格区间</p><p>3、尝试其他关键字</p><a class="btn btn-default mt20" href="javascript:void(0)">显示综合排序的商品列表</a></p>'});


    });




})(window, document)


